define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'userdeposit/index' + location.search,
                    add_url: 'userdeposit/add',
                    edit_url: 'userdeposit/edit',
                    del_url: 'userdeposit/del',
                    multi_url: 'userdeposit/multi',
                    import_url: 'userdeposit/import',
                    table: 'user_deposit',
                }
            });

            var table = $("#table");
            table.on('load-success.bs.table', function (e, data) {

                $("#total_pay").text(data.total_pay);

            });
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},
                        // {field: 'user_id', title: __('User_id')},
                        {field: 'user.username', title: __('User.username'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'user.tel', title: __('User.tel'), operate: 'LIKE'},
                        {field: 'user.name', title: __('User.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'user.contact_name', title: __('User.contact_name'), operate: 'LIKE'},
                        {field: 'user.contact_tel', title: __('User.contact_tel'), operate: 'LIKE'},
                        {field: 'price', title: __('缴纳金额'), operate:false},
                        {field: 'order_no', title: __('Order_no'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'transaction_id', title: __('Transaction_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'tui_order_no', title: __('Tui_order_no'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'ispay', title: __('Ispay'), searchList: {"1":__('Ispay 1'),"0":__('Ispay 0')}, formatter: Table.api.formatter.normal},
                        // {field: 'authen_tui', title: __('Authen_tui'), searchList: {"1":__('Authen_tui 1'),"2":__('Authen_tui 2'),"3":__('Authen_tui 3')}, formatter: Table.api.formatter.normal},
                        // {field: 'reason', title: __('Reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'authen_time', title: __('Authen_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'add_time', title: __('Add_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'pay_time', title: __('Pay_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
                        
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
